<template>
	<view class="earningsParticulars">
		<view class="title">
			<text>{{title}}</text>
			<text>收入明细</text>
		</view>
		<view class="con" v-for="(item,index) in pageResult.list" :key="index">
			<view>{{item.type_name}}</view>
			<view>{{item.created_at}}</view>
			<view>客户：{{item.member_name}}({{item.member_mobile}})</view>
			<view>订单总金额：{{item.order_money}}元</view>
			<view>返利：<text>
					+{{item.money}}元
				</text></view>
		</view>

	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
	export default {
		data() {
			return {
				title: '',
				pageParam: {
					appkey: uni.getStorageSync('appkey'),
					'access-token': uni.getStorageSync('access-token'),
					id: 0,
					page: 0,
					pageSize: 10
				},
				pageResult: {
					list: [],
					isEmpty: false,
					isEnd: false
				}
			}
		},
		methods: {
			getList() {
				var self = this;
				self.pageParam.page++
				serve
					.request({
						url: '/member/royalty/info',
						data: self.pageParam
					})
					.then(res => {
						if(res.code != 200) {
							uni.showToast({
								title:res.message,
								icon: 'none',
								success() {
									setTimeout(function () {
										common.jump('earnings_view')
									}, 2000) 
								}
							});
							return ;
						}
						self.title = res.data.title;
						if (res.data.list && res.data.list.length > 0) {
							self.pageResult.list=self.pageResult.list.concat(res.data.list);
						}
						self.pageResult.isEmpty = self.pageResult.list.length == 0;
						self.pageResult.isEnd = res.data.list.length == 0; 
					});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(options) {
			if (uni.getStorageSync('access-token') == '') {
				common.jump('login');
				return ;
			}
			this.pageParam.id = options.id || 0;
			if(this.pageParam.id == 0) {
				common.jump('earnings_view');
				return ;
			}
			this.pageParam.page=0;
			this.pageResult.list=[];
			this.getList();
		},
		onPullDownRefresh() {
			this.pageParam.page=0;
			this.pageResult.list=[];
			this.getMainInfo();
			this.loadList();
		},
		//触底加载
		onReachBottom() {
			console.log('触底'); 
			if(this.pageResult.isEnd ||this.pageResult.isEmpty){
				return
			}
			this.loadList()
		}
	}
</script>

<style scoped lang="scss">
	.earningsParticulars {
		.title {
			box-sizing: border-box;
			padding: 47rpx 30rpx 6rpx;
			display: flex;
			flex-direction: column;

			text {
				font-size: 32rpx;
				color: #333333;
			}

			text:last-child {

				margin-top: 46rpx;
				font-weight: bold;
			}
		}
		.con{
			box-sizing: border-box;
			padding: 50rpx 30rpx 0rpx;
			border-bottom: 1rpx #F0EDE9 solid;
			view{
				padding-bottom: 50rpx;
				color: #999999;
				font-size: 32rpx;
				text{
					color: #FF5F60;
				}
			}
		}
	}
</style>
